/**
 * 功能:密码修改页面
 * 作者:郜晓俊
 * 时间:2017:05:17
 */
$(document).ready(function () {

    var me = $(this);

    /* VUE -- 绑定到查询条件区域表单，ID为queryForm */
    var queryConditions = new Vue({
        el: '#ChangePwdForm',
        data: {
            myParams: {
                CURRENT_USER: $.cookie('USERNO')
            }
        }
    });

    //Vue.set(queryConditions.myParams,"CURRENT_USER",$.cookie('LOGIN_USERNO'))
    //queryConditions.myParams.CURRENT_USER=$.cookie('LOGIN_USERNO');

    var changepwd = function () {

        app.callAjaxPost(
            '../../../../api/LoginController/changePassword',
            {OLD_PASSWORD:$('#OLD_PWD').val(),NEW_PASSWORD:$('#NEW_PWD').val()},
            function (result) {
            if (result.success) {
                layer.alert('密码修改成功',{icon:1});
                $('#resetBtn').click();
            }
            else {
                layer.alert(result.message, {icon: 2});
                return;
            }
        })

    };

    /* 提交按钮点击 */
    $('#btnSubmit').click(function () {


        if ($('#ChangePwdForm').valid()) {
            if ($('#NEW_PWD').val() == $('#CONFIRM_PWD').val()) {
                changepwd();
            }
            else {
                layer.alert('您两次输入的新密码不一致', {icon: 0});
            }
        } else {
            return;
        }

    });


    /*重置按钮*/
    $('#resetBtn').click(function () {
        $('#ChangePwdForm').find("input")
            .not(':button, :submit, :reset, :hidden, #CURRENT_USER')
            .val('')
            .removeAttr('checked')
            .removeAttr('selected');
        //queryConditions.myParams = {  CURRENT_USER:$.cookie('LOGIN_USERNO')};
    });
});